package com.sskj.lib.router.service;

import android.content.Context;
import android.text.TextUtils;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.facade.template.IProvider;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.HttpHeaders;
import com.lzy.okgo.model.HttpParams;
import com.shizhefei.mvc.MVCHelper;
import com.sskj.common.util.SPUtil;
import com.sskj.lib.Constans;
import com.sskj.lib.SPConfig;
import com.sskj.lib.mvchelper.LoadViewFactory;


@Route(path = "/lib/application")
public class LibService implements IProvider {
    @Override
    public void init(Context context) {
        MVCHelper.setLoadViewFractory(new LoadViewFactory());
        HttpHeaders httpHeaders = new HttpHeaders();
        OkGo.getInstance().addCommonHeaders(httpHeaders);
        String token = SPUtil.get(SPConfig.TOKEN, "");
        String account = SPUtil.get(SPConfig.ACCOUNT, "");
        if (!TextUtils.isEmpty(token)) {
            httpHeaders.put(SPConfig.TOKEN, token);
        }
        if (!TextUtils.isEmpty(account)) {
            httpHeaders.put(SPConfig.ACCOUNT, account);
        }
        httpHeaders.put("systemType", "ANDROID");
        OkGo.getInstance().addCommonHeaders(httpHeaders);
//        HttpParams httpParams = new HttpParams();
//        httpParams.put("systemType", "ANDROID");
//        OkGo.getInstance().addCommonParams(httpParams);
    }
}
